
/*!	brief The Vertex class define the structure of vertex attributes send to the shaders, and the way to interact with them
 
           Workflow overview : A mesh is constitued of vertices. All the vertex a Mesh need will be stored in only one
           vector : the static propertie Vertices in Vertex.
           When a mesh want to create a new Vertex, it'll have to call the static method "New", this will automatically add the vertex
           in the Vertices vector, and give back a pointer for the mesh
           To render the scene, the vertex must be given to a VBO as float *. So, there'll be a phase where all the vertex will be
           inspected and transformed in float * . During this phase, the m_Indice must be defined, for the IBO to work correctly
 */

Vertex = function (position, color, normal, texcoord0)
{
	/****************************/
	/*		Properties			*/
	/****************************/
	
		/*!< Vertex attribute used by GLSL shaders      */
		this.m_Attributes = new Attributes(position, color, normal, texcoord0);	
		
		/*!< Faces connected to the current vertex		*/
		this.m_Faces = new Array();			
		
		/*!< Index of the vertex, used by face to construct IBO and must be  defined during float * construction         */
		this.m_Index;			

 }
 
 Vertex.Vertices = new Array();       			/*!< Store all the application's Vertices on CPU side, not used for rendering, only editing	*/
 
 Vertex.New =  function(position, color, normal, texcoord0)
 {
 if(color==undefined)
 {
	color = new Vec4();
 }
	var vertex = new Vertex(position, color, normal, texcoord0);
	Vertex.Vertices.push(vertex);
	return Vertex.Vertices[Vertex.Vertices.length-1];
 }
 
 Vertex.ToArray= function()
 {
	this.s_Array = new Array();
	
	for(var i=0;i<Vertex.Vertices.length;i++)
	{
		Vertex.Vertices[i].m_Index=i;
		
		for(var j=0; j< Vertex.Vertices[i].m_Attributes.m_Attributes.length; j++)
		{
			this.s_Array.push(Vertex.Vertices[i].m_Attributes.m_Attributes[j].x);
			this.s_Array.push(Vertex.Vertices[i].m_Attributes.m_Attributes[j].y);
			this.s_Array.push(Vertex.Vertices[i].m_Attributes.m_Attributes[j].z);
			this.s_Array.push(Vertex.Vertices[i].m_Attributes.m_Attributes[j].w);
		}
	}
	
	return this.s_Array;
	
 }
		 
	//	 Vertex.prototype.ComputeNormal = function()
	//	 {
		 
	//	 }
		 


	//	


		
			/*! brief The Array method will transform every vertex in the static double vector to transform them for VBO insertion */
		//	Vertex.Array=function()
		//	{
			
		//	}
			
			/*! All the static new function will be used to create Vertex inside meshes */
			
                

